<template>
	<view class="root pt-30">
		<navigator
			v-for="(order, index) in shareReds.list"
			:key="index"
			:style="{ padding: `30rpx` }"
			:url="`/pages/businessBackground/ShareRedDetailed?id=${order.id}`"
			class="mb-30 bgc-fff color-333"
		>
			<label class="fs-28 jc-sb">
				<text>订单状态</text>
				<text>{{ order.activity }} {{ order.actual }}</text>
			</label>
			<view class="fs-26 mt-30 lh-2">
				<text>订单时间 {{ order.createtime_text }}</text>
				<text>订单金额 {{ order.all_money }}</text>
			</view>
		</navigator>
		<uni-load-more :status="loadStatus" :showIcon="!refresherTriggered" />
	</view>
</template>

<script lang="ts">
	import { Vue, Component } from "vue-property-decorator";
	import { Pager } from "@/static/type";

	let requestFlag: boolean = false;
	@Component
	export default class ShareRed extends Vue {
		// component property
		loadStatus: string = "loading";
		shareReds: Pager<AnyObject> = {
			list: [],
			page: 1,
			size: 10,
		};
		onLoad() {
			this.getListData();
		}
		onReachBottom() {
			this.getListData();
		}

		getListData() {
			const { $request, shareReds } = this;
			if (requestFlag || !shareReds.page) return;
			(requestFlag = true), (this.loadStatus = "loading");

			$request
				.get("/index/bounsList", {
					page: shareReds.page,
					size: shareReds.size,
				})
				.then(({ data }) => {
					shareReds.list.push(...data.data);
					shareReds.page = data.current_page < data.last_page ? ++data.current_page : 0;
					this.loadStatus = shareReds.page ? "more" : "noMore";
				})
				.finally(() => (requestFlag = false));
		}
	}
</script>

<style lang="scss" scoped>
	// scss
	page {
		height: 100%;
	}
</style>